<?php

namespace app\listener\couponOrder;

use app\event\SupplierCreateOrder;
use app\model\CouponOrder;

class CouponOrderCreate
{

    /**
     * 事件监听处理
     * @param SupplierCreateOrder $event
     * @return mixed
     */
    public function handle($event)
    {
        $couponOrder = $event->couponOrder;

        // 小类型配置
        if ($couponOrder->type != CouponOrder::TYPE_COUPON_SELF_EMPLOYED) {
            return true;
        }


        if ($couponOrder->status != CouponOrder::C_STATUS_NO_SUBMIT) {
            return true;
        }
        
        $couponOrder->supplier_status = CouponOrder::SUPPLIER_STATUS_SUBMIT;
        $couponOrder->status = CouponOrder::C_STATUS_SUBMIT;
        $couponOrder->save();
    }
}